Skip to content

fix(web): Add support for adaptive thinking parameters#1127

Merged
brendan-kellam merged 4 commits intomainfrom
bkellam/support_opus_4_7
Apr 16, 2026
Merged

fix(web): Add support for adaptive thinking parameters#1127
brendan-kellam merged 4 commits intomainfrom
bkellam/support_opus_4_7

Conversation

@brendan-kellam
Copy link
Copy Markdown
Contributor

@brendan-kellam brendan-kellam commented Apr 16, 2026

Fixes #1123

Summary by CodeRabbit

  • Improvements
    • Anthropic models: Claude Opus 4.7 now uses an adaptive "thinking" mode with summarized display; other Anthropic models continue using the enabled thinking mode with token-budget controls.
  • Bug Fixes
    • Fixed an error that occurred when using Claude Opus 4.7 with the previous thinking configuration.

@github-actions

This comment has been minimized.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 16, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 366915da-ae4d-4f56-b66e-cff7a33c8c09

📥 Commits

Reviewing files that changed from the base of the PR and between 65278a8 and f39ce02.

📒 Files selected for processing (1)
  • packages/web/src/features/chat/utils.server.ts

Walkthrough

Anthropic provider thinking options in getAISDKLanguageModelAndOptions now branch on modelId: claude-opus-4-7 uses adaptive thinking ({ type: "adaptive", display: "summarized" }); other Anthropic models retain enabled thinking with budgetTokens from env.ANTHROPIC_THINKING_BUDGET_TOKENS.

Changes

Cohort / File(s) Summary
Anthropic Provider Configuration
packages/web/src/features/chat/utils.server.ts
Added conditional branching for Anthropic thinking options: claude-opus-4-7{ type: "adaptive", display: "summarized" }; others → { type: "enabled", budgetTokens: env.ANTHROPIC_THINKING_BUDGET_TOKENS }.
Changelog
CHANGELOG.md
Added ### Fixed entry documenting the fix for claude-opus-4-7 error about unsupported thinking.type.enabled (refs issue #1123).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding support for adaptive thinking parameters to fix the Opus 4.7 incompatibility issue.
Linked Issues check ✅ Passed The code changes directly address issue #1123 by implementing conditional logic for Opus 4.7 to use adaptive thinking mode instead of enabled mode, resolving the reported error.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the Opus 4.7 thinking configuration issue; no unrelated modifications were introduced.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bkellam/support_opus_4_7

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
packages/web/src/features/chat/utils.server.ts (1)

213-227: Consider making thinking mode configurable rather than hardcoded per model.

Hardcoding the adaptive-vs-enabled branch by modelId couples the provider-option shape to a single model string. As more Anthropic models support adaptive thinking, this if/else will grow. A cleaner path is to expose a thinkingMode (or similar) field on the Anthropic LanguageModel config schema — mirroring how reasoningEffort / thinkingBudget are already surfaced for OpenAI/Google — and default it based on model when unset. Not blocking for this PR.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/web/src/features/chat/utils.server.ts` around lines 213 - 227, The
current logic hardcodes adaptive vs enabled thinking via
isAdaptiveThinkingSupported and switches providerOptions.anthropic based on
modelId (in the anthropic(modelId) block); instead, add an optional thinkingMode
(or similar) on the Anthropic LanguageModel config and use that if provided,
otherwise default thinkingMode based on modelId (e.g., default to "adaptive" for
known models), then build providerOptions.anthropic from that thinkingMode and
env.ANTHROPIC_THINKING_BUDGET_TOKENS; update places that construct models to
accept the new config and remove the direct modelId-only branching so
AnthropicProviderOptions is derived from thinkingMode rather than hardcoded
model checks.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/web/src/features/chat/utils.server.ts`:
- Around line 220-226: The object literal assigned to thinking uses an
inconsistent quoted key "display"; update it to use an unquoted identifier
(display: "summarized") so it matches the style of the sibling type key and
remains compatible with the AnthropicProviderOptions shape—edit the ternary
branch that references thinking, isAdaptiveThinkingSupported, and
env.ANTHROPIC_THINKING_BUDGET_TOKENS to remove the quotes around the display
key.
- Around line 213-214: The exact equality check for modelId in the
isAdaptiveThinkingSupported assignment is brittle and will miss dated Anthropic
aliases like "claude-opus-4-7-20260101"; change the check to match by prefix or
pattern (e.g., use modelId.startsWith('claude-opus-4-7') or a RegExp/allowlist)
so any dated suffix still yields true for isAdaptiveThinkingSupported, and
update any related conditionals that rely on that constant (search for
isAdaptiveThinkingSupported and modelId usage to adjust accordingly).

---

Nitpick comments:
In `@packages/web/src/features/chat/utils.server.ts`:
- Around line 213-227: The current logic hardcodes adaptive vs enabled thinking
via isAdaptiveThinkingSupported and switches providerOptions.anthropic based on
modelId (in the anthropic(modelId) block); instead, add an optional thinkingMode
(or similar) on the Anthropic LanguageModel config and use that if provided,
otherwise default thinkingMode based on modelId (e.g., default to "adaptive" for
known models), then build providerOptions.anthropic from that thinkingMode and
env.ANTHROPIC_THINKING_BUDGET_TOKENS; update places that construct models to
accept the new config and remove the direct modelId-only branching so
AnthropicProviderOptions is derived from thinkingMode rather than hardcoded
model checks.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 50102019-c71f-4fe1-953c-1191a2f09c74

📥 Commits

Reviewing files that changed from the base of the PR and between 4ab2d76 and 13f5545.

📒 Files selected for processing (1)
  • packages/web/src/features/chat/utils.server.ts

Comment thread packages/web/src/features/chat/utils.server.ts Outdated
Comment thread packages/web/src/features/chat/utils.server.ts
@brendan-kellam brendan-kellam merged commit d89c5a1 into main Apr 16, 2026
6 checks passed
@brendan-kellam brendan-kellam deleted the bkellam/support_opus_4_7 branch April 16, 2026 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Opus 4.7 does not work with Sourcebot

1 participant